/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ch02;

/**
 *
 * @author osa
 */
public class RadioBase {
    private boolean power = false;
    private int volume = 30;
    private Channel[] channel;

    public void turnOn() {
        this.power = true;
    }
    public void turnOff() {
        this.power = false;
    }
    public boolean getTurn() {
        return this.power;
    }

    public void volumeUp(int inc) {
        this.volume = this.volume + inc;
        if (this.volume > 100) {
            this.volume = 100;
        }
    }
    public void volumeDown(int dec) {
        this.volume = this.volume - dec;
        if (this.volume < 0) {
            this.volume = 0;
        }
    }
    public int getVolume() {
        return this.volume;
    }

    public void searchChannels() {
        channel = new Channel[3];
        channel[0] = new Channel("NHK", 684);
        channel[1] = new Channel("TBS", 960);
        channel[2] = new Channel("NIPPON", 1242);
    }
    public void checkAllChannels() {
        for (Channel ch : channel) {
            System.out.println(ch.getName() + " : " + ch.getFrequency());
        }
    }
    public void adjustFrequency(int ch, int freq) {
        channel[ch].setFrequency(freq);
    }
}

